//
//  LJYMyTableViewCell.m
//  WWLNetease
//
//  Created by 李锦耀 on 15/12/23.
//  Copyright © 2015年 Echo.Jobs. All rights reserved.
//

#import "LJYMyTableViewCell.h"

@interface LJYMyTableViewCell ()

@property(nonatomic, strong)UIImageView *titleImage;
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *sourceLabel;
@property(nonatomic, strong)UIButton *detailButton;
@property(nonatomic, strong)NSMutableArray *unlikeReason;
@property(nonatomic, strong)NSDictionary *attrDict3;

@end

@implementation LJYMyTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        _unlikeReason = [NSMutableArray array];
        UIImageView *image= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"u=1958105358,1173351178&fm=21&gp=0.jpg"]];
        self.backgroundView = image;
        [self creatAction];
    }
    return self;
}

-(void)creatAction
{
    self.attrDict3 = @{ NSStrokeWidthAttributeName: @(3),
                        NSStrokeColorAttributeName: [UIColor colorWithRed:0.69 green:0 blue:0 alpha:1],
                        NSFontAttributeName: [UIFont systemFontOfSize:14] };
    _titleImage = [[UIImageView alloc] init];
    _titleImage.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_titleImage];
    [_titleImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(15);
        make.left.mas_equalTo(13);
        make.width.equalTo(self.contentView.mas_width).multipliedBy(0.3);
        make.height.equalTo(self.contentView.mas_height).multipliedBy(0.6);
    }];
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.backgroundColor = [UIColor clearColor];
    _titleLabel.font = [UIFont boldSystemFontOfSize:16];
    _titleLabel.textColor = [UIColor colorWithRed:0.69 green:0 blue:0 alpha:1];
    _titleLabel.numberOfLines = 0;
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(15);
        make.left.equalTo(self.titleImage.mas_right).offset(10);
        make.right.equalTo(self.contentView.mas_right).offset(-5);
        make.bottom.equalTo(self.titleImage).offset(-5);
    }];
    
    _sourceLabel = [[UILabel alloc] init];
    _sourceLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_sourceLabel];
    [_sourceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.titleImage);
        make.top.equalTo(self.titleImage.mas_bottom).offset(8);
        make.bottom.equalTo(self.contentView).offset(-4);
        make.right.mas_equalTo(-100);
        
    }];
    
    _detailButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:_detailButton];
    _detailButton.backgroundColor = [UIColor clearColor];
    [_detailButton mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.sourceLabel.mas_right).offset(6);
        make.top.equalTo(self.titleImage.mas_bottom).offset(8);
        make.right.equalTo(self.contentView.mas_right);
        make.bottom.equalTo(self.contentView).offset(-4);
    }];
    [_detailButton addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    
}
-(void)setRecommend:(LJYRecommendModel *)recommend
{
    [self.titleImage sd_setImageWithURL:[NSURL URLWithString:recommend.img] placeholderImage:[UIImage imageNamed:@"u=1625671141,2113623839&fm=21&gp=0.jpg"]];
    self.titleLabel.text = recommend.title;
//    self.sourceLabel.text = recommend.source;
       self.sourceLabel.attributedText = [[NSAttributedString alloc] initWithString: recommend.source attributes: self.attrDict3];
    self.unlikeReason = recommend.unlikeReason;
}

-(void)buttonAction
{
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
